import { ScrollView, View } from "@tarojs/components";
import { useLoad } from "@tarojs/taro";
import { AtDivider, AtTabBar } from "taro-ui3";
import { useState } from "react";
import Mood from "./Mood";
import Follow from "./Follow";
import Chat from "@/components/Chat";

import styled from "./index.module.scss";
import Taro from "@tarojs/taro";



export default function Index() {
  useLoad(() => {
    console.log("Page loaded.");
    Taro.navigateTo({ url: '/login/pages/index' })
  });

  const [selected, setSelected] = useState<number>(0);

  const handleClick = (index: number) => {
    setSelected(index);
  };

  const chatMessage = [
    {
      id: '1',
      avatar: "https://taro-ui.jd.com/img/wxapp.jpg",
      name: "小智AAAAAA",
      time: "刚刚",
      type: "text",
      createAt: "2021-08-30 15:46",
      content: "宫崎骏说：既然选择喜欢了你 哪有那么容易放下 我不知道我有多喜欢 但是如果去见你 我一定跑的 在本向你的路上 风都是甜的～",
    },
    {
      id: '2',
      avatar: "https://taro-ui.jd.com/img/wxapp.jpg",
      name: "小智BBBBB",
      time: "一天前",
      type: "text",
      createAt: "2021-08-30 15:46",
      content: "宫崎骏说：既然选择喜欢了你 哪有那么容易放下 我不知道我有多喜欢 但是如果去见你 我一定跑的 在本向你的路上 风都是甜的～",
    }
  ];

  return (
    <View className={styled['home-container']}>
      <ScrollView className={styled['home-main']} scrollY enableFlex>
        <Mood />
        <Follow />
        <View className={styled['chat-container']}>
          <AtDivider content='' />
          <Chat list={chatMessage}/>
        </View>
      </ScrollView>
      <AtTabBar
        fixed
        tabList={[
          { title: "", iconType: "home", text: "" },
          { title: "", iconType: "map-pin" },
          { title: "", iconType: "file-new", text: "", max: 99 },
          { title: "", iconType: "bell", text: "", max: 99 },
          { title: "", iconType: "user", text: "", max: 99 },
        ]}
        onClick={handleClick}
        current={selected}
      />
    </View>
  );
}
